/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ru.jSkyRoom.bridge.major;

import ru.jSkyRoom.interfaces.major.GameSetting;
import skyproc.GMST;
import skyproc.GMST.GMSTType;
import static skyproc.GMST.GMSTType.Bool;
import static skyproc.GMST.GMSTType.Int;

/**
 *
 * @author Rakev
 */
public class GameSettingBridge<T> extends MajorBridge<GMST> implements GameSetting<T> {

    public GameSettingBridge(GMST adapting) {
        super(adapting);
    }

    @Override
    public GMSTType getGMSTType() {
        return getRawObject().getGMSTType();
    }

    @Override
    public T getValue() {
        switch (getGMSTType()) {
            case Bool:
                return (T) (Boolean) getRawObject().getBool();
            case Int:
                return (T) (Integer) getRawObject().getInt();
            case Float:
                return (T) (Float) getRawObject().getFloat();
            case String:
                return (T) (String) getRawObject().getString();
        }
        return null;
    }

    @Override
    public void setValue(T data) {
        switch (getGMSTType()) {
            case Bool:
                getRawObject().setData((Boolean) data);
            case Int:
                getRawObject().setData((Integer) data);
            case Float:
                getRawObject().setData((Float) data);
            case String:
                getRawObject().setData((String) data);
        }
    }
}
